import { createStore,Store,StoreOptions } from 'vuex';
import {IRootState} from "../types/root-types"
const store = createStore<IRootState>({
    state: {
        username:"xiaowang",
        users:[
            {id:1,name:"王小二"}
        ]
    },
    getters: {},
    mutations: {
        changeUsername(state,payload){
            state.username = payload
        }
    },
    actions: {
        asyncChangeUsername(context,payload){
            setTimeout(() => {
                context.commit("changeUsername",payload)
            }, 1000);
        }
    },
    modules: {}
})
export default store
